package net.kts.attraction.subway.adapter;

import java.util.List;

import net.kts.attraction.subway.smallpass.model.StationName;
import net.kts.define.AttractionDefine;
import net.kts.main.R;






import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class SubwayAdapter extends ArrayAdapter<StationName> {
	
	private Context context = null;
	private List<StationName> stationNameList = null;

	public SubwayAdapter(Context context, int textViewResourceId,
			List<StationName> objects) {
		super(context, textViewResourceId, objects);
		this.context  = context;
		this.stationNameList = objects;
		// TODO Auto-generated constructor stub
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View v = convertView;
        if (v == null) {
            LayoutInflater vi = (LayoutInflater)this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.attraction_subway_ready_row, null);
        }
        StationName stationName = this.stationNameList.get(position);
        if (stationName != null) {
        		ImageView lineImg = (ImageView)v.findViewById(R.id.curSubwayListLineImg);
                TextView stName = (TextView) v.findViewById(R.id.curSubwayListStationName);
                TextView stDistance = (TextView) v.findViewById(R.id.curSubwayListDistance);
                
                if(lineImg != null) {
                	lineImg.setImageResource(AttractionDefine.getLineDrawableResourceId(stationName.getLineNum()));
                }
                
                if (stName != null){
                	stName.setText("StationName : " + stationName.getStationName());                            
                }
                if(stDistance != null){
                	stDistance.setText("Distance : "+ stationName.getStationCode() + "M");
                }
        }
        return v;
	}
	


}
